﻿using System;
using System.Collections.Generic;
using System.Text;
using ZLDC.Common.Estate;
using System.Data;

namespace ZLDC.Topo.BLL.Estate
{
    public class OperationlogBLL
    {
                                                                        public static string p_operationlog_insert(string TableName, int TableId, int typeid, string content)
        {
            string operateType = "";
            switch (typeid)
            {
                case 1 :
                    operateType = "系统登录";
                    break;
                case 2:
                    operateType = "楼盘字典";
                    break;
                case 3:
                    operateType = "盘源管理";
                    break;
                case 4:
                    operateType = "客源管理";
                    break;
                case 5:
                    operateType = "用户管理";
                    break;
               
               
            }

            string outmsg = "";
            int newid = 0;
            string ip = _Tools.GetIp();
            int operateUserId = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID, 0);
            int operatedeptid = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID, 0);
            string operateUser = _Utility.GetInfoBySession().m_sUserName; 

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.OperationlogDAL.p_operationlog_insert(operateUserId, operateUser, TableName, TableId, operateType, content, ip,operatedeptid, out outmsg, out newid, db);
            }

            return outmsg;
        }

                                                                        public static string p_operationlog_insert(string TableName, int TableId, string typeName, string content)
        {            
            string outmsg = "";
            int newid = 0;
            string ip = _Tools.GetIp();
            int operateUserId = _Convert.ToInt(_Utility.GetInfoBySession().m_sUserID, 0);
            int operatedeptid = _Convert.ToInt(_Utility.GetInfoBySession().m_sDeptID, 0);
            string operateUser = _Utility.GetInfoBySession().m_sUserName;

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.OperationlogDAL.p_operationlog_insert(operateUserId, operateUser, TableName, TableId, typeName, content, ip, operatedeptid, out outmsg, out newid, db);
            }

            return outmsg;
        }

                                                                        public static string p_operationlog_list_table(int page, int pagesize, string condition)
        {
            DataTable dt = null;
            int total = 0;                       int pageall = 0;         
            using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.OperationlogDAL.p_operationlog_list_table(page, pagesize, condition, ref total, db);
            }

            pageall = _Utility.GetPageAll(pagesize, total);      
            _Json json = new _Json(dt,"yyyy-MM-dd HH:mm:ss");
            return "{page:{currentpage:'" + page + "',pagesize:'" + pagesize + "',total:'" + total + "',pageall:'" + pageall + "'},record:" + json.ToJson() + "}";
        }

    }
}
